import pytest

from common.Base_request import Base_request
from day1.requests_test import CommonApi
from common.yaml_tools import YamlTools


test_data1 = YamlTools.read_yaml_file("loginapi_data.yaml")[0]
test_data2 = YamlTools.read_yaml_file("bankloginapi_data.yaml")[0]
register_test_data = YamlTools.read_yaml_file("register_data.yaml")[0]
class TestLogin:
    @ pytest.mark.parametrize("loginapi",test_data1["parametrize"])
    def test_login(self,loginapi):
        result = CommonApi.fun2(loginapi["data"]["userName"],loginapi["data"]["password"])
        assert result == loginapi["expect"], "登录失败"

    @pytest.mark.parametrize("bankloginapi",test_data2["parametrize"])
    def test_ALL(self,bankloginapi):
        result = Base_request.excute_api_request(request=test_data2[r"request"],testcase=bankloginapi)
        assert result["message"] == bankloginapi["expect"],"登录失败"


    @pytest.mark.parametrize("register", register_test_data["parametrize"])
    def test_register(self,register):
        result = CommonApi.test_register_success()
        assert result == register["expect"]

